#ifndef GROUPCHAT_H
#define GROUPCHAT_H

#include <QWidget>
#include<QScrollBar>
#include <QScrollArea>
#include <QLineEdit>
#include <QVBoxLayout>
#include <QPushButton>
#include <QTextCursor>
#include <QMutex>
#include"chatbubble.h"
namespace Ui {
class groupChat;
}

class groupChat : public QWidget
{
    Q_OBJECT

public:
    explicit groupChat(QWidget *parent = nullptr);
    ~groupChat();

    //静态成员函数
    static groupChat*getInstance();
    static void  release();

    void updateGroupShowMsg(QString msg,QString timeText);

    //设置消息格式
    void appendLine(const QString &text, const QColor &color, Qt::Alignment alignment,const QColor& bgColor);

    void appendLine(const QString &text,const QString &timeText,int bubbleType);

private slots:
    void sendMessage();
private:
    Ui::groupChat *ui;

    QVBoxLayout *chatLayout;
    QLineEdit *input;
    QScrollArea *scrollArea;
    // QTextCursor m_cursor;

    //静态成员变量类内声明
    static groupChat* m_instance;
    static QMutex m_mutex;
};

#endif // GROUPCHAT_H
